<?php
/**
 * Created by JetBrains PhpStorm.
 * User: zhouyang
 * Date: 13-7-15
 * Time: 下午4:31
 * To change this template use File | Settings | File Templates.
 */
class CatesModel extends Model{
    //根据cate_id 获取cate 信息
    public function get($cate_id){
        return $this->dbreader()->get($cate_id);
    }

    //获取cate 列表<带分页>
    public function getCateList($curr_page,$per_page,$filter = array()){
        return $this->dbreader()->getCateList($curr_page,$per_page,$filter);
    }

    //刷新分类树的预排序
    public function refreshCateTree($right_value,$span = '+2'){
        return $this->dbreader()->refreshCateTree($right_value,$span = '+2');
    }

    //由于树的顶部是虚拟的：left_value:0,right_value:max_value
    public function getMaxRightValue(){
        return $this->dbreader()->getMaxRightValue();
    }

    public function addCate($cate_name,$action,$parent_cate_id,$is_show){
        return $this->dbreader()->addCate($cate_name,$action,$parent_cate_id,$is_show);
    }

    //根据左右值获取子分类，包含本身
    public function getCateByLR($left_value,$right_value){
        return $this->dbreader()->getCateByLR($left_value,$right_value);
    }

    public function delAllCate($cate_id){
        return $this->dbreader()->delAllCate($cate_id);
    }

    public function updateCate($cate_id,$cate_name,$action,$parent_cate_id,$is_show){
        return $this->dbreader()->updateCate($cate_id,$cate_name,$action,$parent_cate_id,$is_show);
    }

    //获取用户拥有权限的菜单树
    public function getTree($cate_id = 0,$filter_show = false,$filter_child = false){
        return $this->dbreader()->getTree($cate_id,  $filter_show, $filter_child);
    }
}